import axios from 'axios';
import { DeviceMaintenance,DeleteDeviceMaintenance} from '../models/warehous-devicemaintenance -input'
import { DeviceMaintenancePageInput} from '../models/warehous-devicemaintenance -page-input.'
import { AdminResultWarehouse } from '../models/result-pagelist-warehouse';
import { serveConfig } from '../../utils/axios-utils';

// Some imports not used depending on template conditions
// @ts-ignore


const BaseUrl=(window as any).__env__.VITE_API_URL
import { axiosInstance } from '/@/utils/axios-utils' 

/** 
 * 获取所有设备
 * @param file 导入的文件对象
 * @returns 导入文件操作的响应结果
 */
export function GetDevicePageListApi(formData:DeviceMaintenancePageInput) {
    return axiosInstance<ResponseDate>({
      //responseType: 'blob',
      url: BaseUrl + '/api/Device/GetDevicePageList',
      method: 'POST',
      data: formData
    });
  }
  /** 
 * 修改
 * @param file 导入的文件对象
 * @returns 导入文件操作的响应结果
 */
export function UpdateDeviceApi(formData:DeviceMaintenance) {
    return axiosInstance<ResponseDate>({
      //responseType: 'blob',
      url: BaseUrl + '/api/Device/UpdateDevice',
      method: 'POST',
      data: formData
    });
  }
  /** 
 * 新增
 * @param file 导入的文件对象
 * @returns 导入文件操作的响应结果
 */
export function InseertDeviceApi(formData:DeviceMaintenance) {
    return axiosInstance<ResponseDate>({
      //responseType: 'blob',
      url: BaseUrl + '/api/Device/InsertDevice',
      method: 'POST',
      data: formData
    });
  }
interface ResponseDate<T=any>{
    code:string,
    message:string,
    result:T
  }
  /** 
   * 导出
   * @param data 导出条件
   * @param responseType 返回类型
   * @returns 导出文件
   */
  export function DeviceexportApi(data:any)
  {
  // 根据调用方式修改请求配置，添加 responseType 为 'blob'
  return axiosInstance<Blob>({
    responseType: 'blob',
      url: BaseUrl+'/api/Device/DeviceExportExcel',
      method: 'POST',
      data
    })
  }

    /** 
 * 导入文件操作
 * @param file 导入的文件对象
 * @returns 导入文件操作的响应结果
 */
export function DeviceinportApi(formData:any) {
  return axiosInstance<ResponseDate>({
    //responseType: 'blob',
    url: BaseUrl + '/api/Device/ImportDevice',
    method: 'POST',
    data: formData
  });
}
  
    /**
   * 下载文件
   * @param data 上传所需参数
   * @returns 上传文件的响应
   * @example
   * const response = await uploadApi({ file: file });
   */
 export function DownloadDeviceApi(params?: Record<string, any>)  {
     return axiosInstance<Blob>({
       responseType: 'blob',
       url: BaseUrl + '/api/Device/DownloadDeviceTemplate',
       method: 'GET',
       params
     });
   }
    /**
   * 删除库位信息
   */
    export function DeleteDeviceApi(data: any) {
        return axiosInstance<ResponseDate>({
    
            url: BaseUrl + '/api/Device/DeleteDevice',
            method: 'Delete',
            data
        })
    }

  /**
   * 批量删除库位信息
   */
  export function BatchDeleteDeviceApi(data: any[]) {
      return axiosInstance<ResponseDate>({
  
          url: BaseUrl + '/api/Device/BatchDeleteDevice',
          method: 'Delete',
          data
      })
  }